public class Passing1DArraysToMethods{
  public static void main(String[] args){
    double[] grades = {80.0, 65.5, 40.0, 72.5, 90.0, 35.8, 56.5};
    
    System.out.print("The grades are: ");
    displayArray(grades);
    
    double average = calculateAverage(grades);
    System.out.println("\nThe average is " + average);
    
  }
  
  private static double calculateAverage(double[] x){
  	double sum = 0;
  	for(int k = 0; k < x.length; k++)
  		sum += x[k];
  		
  	return sum / x.length;
  }
  
  private static void displayArray(double[] array){
  	for(int k = 0; k < array.length; k++)
      System.out.print(array[k] + "  ");
  }
}